# -*- coding: utf-8 -*-
"""
Created on Sun Nov 13 19:12:28 2022

@author: LUO
"""

from PyQt5 import QtCore, QtWidgets, QtGui

class MyIconButton(QtWidgets.QPushButton):

   def __init__(self, btnTxt="", btnIcon=""):
      super().__init__()

      self.thisLayout = QtWidgets.QVBoxLayout()
      self.IconLab = QtWidgets.QLabel()
      self.TextLab = QtWidgets.QLabel()

      self.IconLab.setPixmap(QtGui.QPixmap(btnIcon))
      self.IconLab.setAlignment(QtCore.Qt.AlignCenter)
      self.IconLab.setScaledContents(True)
      self.IconLab.setMouseTracking(False)
      self.IconLab.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)

      self.TextLab.setText(btnTxt)
      self.TextLab.setAlignment(QtCore.Qt.AlignCenter)
      self.TextLab.setWordWrap(True)
      self.TextLab.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
      self.TextLab.setMouseTracking(False)
      self.TextLab.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)

      self.thisLayout.addWidget(self.IconLab)
      self.thisLayout.addWidget(self.TextLab)

      self.thisLayout.setSpacing(5)
      self.thisLayout.setContentsMargins(5, 5, 5, 5)

      self.setFlat(True)

      self.TextLab.setFont(QtGui.QFont('times', 14, QtGui.QFont.Black))
      #self.TextLab.setStyleSheet("Color: blue;")

      self.setText("")

      self.setLayout(self.thisLayout)